home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / nt / slint.nt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  4.3 KB  |  211 lines

  1. /* Slang interface to the Midnight Commander for Windows NT
  2.    This emulates some features of ncurses on top of slang
  3.    S-lang is not fully consistent between its Unix and non-Unix versions.
  4.    
  5.       
  6.    This program is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2 of the License, or
  9.    (at your option) any later version.
  10.    
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <config.h>
  21. #include <stdio.h>
  22. #include <windows.h>
  23. #include "tty.h"
  24. #include "mad.h"
  25. #include "color.h"
  26. #include "util.h"
  27. #include "mouse.h"        /* Gpm_Event is required in key.h */
  28. #include "key.h"        /* define_sequence */
  29. #include "main.h"        /* extern: force_colors */
  30. #include "win.h"        /* do_exit_ca_mode */
  31.  
  32. #ifdef HAVE_SLANG
  33.  
  34. //??
  35. static void slang_sigterm ()
  36. {
  37.     SLsmg_reset_smg ();
  38. }
  39.  
  40. static int slinterrupt;
  41.  
  42. void enable_interrupt_key(void)
  43. {
  44.     SLang_set_abort_signal(NULL);
  45.     slinterrupt = 1;
  46. }
  47. void disable_interrupt_key(void)
  48. {
  49.     slinterrupt = 0;
  50. }
  51. int got_interrupt ()
  52. {
  53.     int t;
  54.     t = slinterrupt ? SLKeyboard_Quit : 0;
  55.     SLKeyboard_Quit = 0;
  56.     return t;
  57. }
  58.  
  59. /* Only done the first time */
  60. void slang_init (void)
  61. {
  62.     SLtt_get_terminfo ();
  63.     SLang_init_tty (XCTRL('c'), 1, 0);    
  64.     slang_prog_mode ();
  65.     load_terminfo_keys ();
  66. }
  67.  
  68. /* Done each time we come back from done mode */
  69. void slang_prog_mode (void)
  70. {
  71.     SLsmg_init_smg ();
  72.     SLsmg_touch_lines (0, LINES);
  73. }
  74.  
  75. /* Called each time we want to shutdown slang screen manager */
  76. void slang_shell_mode (void)
  77. {
  78.  
  79. }
  80.  
  81. void slang_shutdown ()
  82. {
  83.     slang_shell_mode ();
  84.     do_exit_ca_mode ();
  85.     SLang_reset_tty ();
  86.  
  87.     /* reset the colors to those that were
  88.      * active when the program was started up
  89.       (not written)
  90.      */
  91. }
  92.  
  93. /* keypad routines */
  94. void slang_keypad (int set)
  95. {
  96. //    enable keypad strings
  97. // ?
  98. }
  99.  
  100. static int no_slang_delay;
  101.  
  102. void set_slang_delay (int v)
  103. {
  104.     no_slang_delay = v;
  105. }
  106.  
  107. void hline (int ch, int len)
  108. {
  109.     int last_x, last_y;
  110.  
  111.     last_x = SLsmg_get_column ();
  112.     last_y = SLsmg_get_row ();
  113.     
  114.     if (ch == 0)
  115.     ch = ACS_HLINE;
  116.  
  117.     if (ch == ACS_HLINE){
  118.     SLsmg_draw_hline (len);
  119.     } else {
  120.     while (len--)
  121.         addch (ch);
  122.     }
  123.     move (last_y, last_x);
  124. }
  125.  
  126. void vline (int character, int len)
  127. {
  128.     if (!slow_terminal){
  129.     SLsmg_draw_vline (len);
  130.     } else {
  131.     int last_x, last_y, pos = 0;
  132.  
  133.     last_x = SLsmg_get_column ();
  134.     last_y = SLsmg_get_row ();
  135.  
  136.     while (len--){
  137.         move (last_y + pos++, last_x);
  138.         addch (' ');
  139.     }
  140.     move (last_x, last_y);
  141.     }
  142. }
  143.  
  144. void init_pair (int index, char *foreground, char *background)
  145. {
  146.     SLtt_set_color (index, "", foreground, background);
  147. }
  148.  
  149.  
  150. int has_colors ()
  151. {
  152.     /* No terminals on NT, make default color */
  153.     if (!disable_colors)
  154.         SLtt_Use_Ansi_Colors = 1;
  155.     
  156.     /* Setup emulated colors */
  157.     if (SLtt_Use_Ansi_Colors){
  158.     init_pair (A_REVERSE, "black", "white");
  159.     } else {
  160.     SLtt_set_mono (A_BOLD,    NULL, SLTT_BOLD_MASK);
  161.     SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
  162.     SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
  163.     }
  164.     return SLtt_Use_Ansi_Colors;
  165. }
  166.  
  167. void attrset (int color)
  168. {
  169.     if (!SLtt_Use_Ansi_Colors){
  170.     SLsmg_set_color (color);
  171.     return;
  172.     }
  173.     
  174.     if (color & A_BOLD){
  175.     if (color == A_BOLD)
  176.         SLsmg_set_color (A_BOLD);
  177.     else
  178.         SLsmg_set_color ((color & (~A_BOLD)) + 8);
  179.     return;
  180.     }
  181.  
  182.     if (color == A_REVERSE)
  183.     SLsmg_set_color (A_REVERSE);
  184.     else
  185.     SLsmg_set_color (color);
  186. }
  187.     
  188. void load_terminfo_keys ()
  189. {
  190. }
  191.  
  192. int getch ()
  193. {
  194.     if (no_slang_delay)
  195.     if (SLang_input_pending (0) == 0)
  196.         return -1;
  197.  
  198.     return SLang_getkey ();
  199. }
  200.  
  201. extern int slow_terminal;
  202.  
  203. #else
  204.  
  205. /* Non slang builds do not understand got_interrupt */
  206. int got_interrupt ()
  207. {
  208.     return 0;
  209. }
  210. #endif /* HAVE_SLANG */
  211.